#include "sys.h"

unsigned char code smg[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff};
u8 NixieBuff[] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
u8 smg1,smg2,smg3,smg4,smg5,smg6,smg7,smg8;
void hc138(u8 chn)
{
	switch(chn)
	{
		case 0: P2 = (P2&0x1f);break;
		case 4: P2 = (P2&0x1f)|0x80;break;
		case 5: P2 = (P2&0x1f)|0xa0;break;
		case 6: P2 = (P2&0x1f)|0xc0;break;
		case 7: P2 = (P2&0x1f)|0xe0;break;
	}
}

void allInit()
{
	P0 = 0xff;
	hc138(4);
	hc138(0);
	
	P0 = 0x00;
	hc138(5);
	hc138(0);
	
	P0 = 0xff;
	hc138(7);
	hc138(0);
}

void nixieScan()
{
	static u8 index;
	P0 = 0xff;
	hc138(7);
	hc138(0);

	P0 = 0x01 << index;
	hc138(6);
	hc138(0);
	
	P0 = NixieBuff[index];
	hc138(7);
	hc138(0);
	
	index++;
	index &= 0x07;
}

void nixieshow()
{
	
}